INSTRUCTIONS:

  • Follow the instructions on the stage to complete this interactive learning activity.
  • Look out for key terms marked with a ★!
  • Sometimes you will have to complete a task on the stage to continue. Pay attention!
  • At the end of the activity click Submit and Next to move on!

To navigate the page using the TAB key, first press ESC to exit the code editor.

import codesters import random from codesters.demo import Demo from codesters import Text # Set constants stage_height = float(stage.get_stage_height()) stage_width = float(stage.get_stage_width()) offstage_below = -1000 # Use as y value to create objects below the stage # Create Demo instance demo = Demo() # Set up stage stage.auto_cache_off() lightener = codesters.Rectangle(0, 0, stage_width, stage_height, "black") lightener.set_opacity(0.3) lightener.hide() stage.set_background_color("black") stage.disable_floor() # Create random letters/characters to drop down the stage chars = [] for counter in range(60): x = random.randint(-550, 550) binary = codesters.Text(chr(random.randint(33, 255)), x, 300, "green") binary.set_y_speed(random.randint(-3, -1)) binary.set_physics_on() binary.set_opacity(random.random()) chars.append(binary) # Moves the characters down the stage at random speeds; # when they reach the bottom, they move to a new random x-coordinate and the top of the stage def interval(): for char in chars: if char.get_y() <= -stage_height/2: char.go_to(random.randint(-550, 550), 310) char.set_y_speed(random.randint(-3, -1)) # char.set_opacity(random.randint(1,10)/10) stage.event_interval(interval, 0.05) # Create Matrix Background stage.set_background_color("black") guide = demo.create_sprite_off_screen("person20", 0, -110, 1.25) # Title Cards guide_text = codesters.Text("Welcome to Cybersecurity", 0, 200) guide_text.set_text_size(40) guide_text.set_text_background("silver", "white", 0.85) guide_text_2 = codesters.Text("Click the blue Next button to continue!", 0, 150) guide_text_2.set_text_size(20) guide_text_2.set_text_background("silver", "white", 0.85) demo.continue_action() guide_text_2.set_y(120) guide_text.set_text_width(800) guide_text.set_text("What is cybersecurity?") guide_text_2.set_text_width(800) guide_text_2.set_text("Let's break the word cybersecurity down into its two parts:") stage.wait(1) demo.continue_action() # Create the two word parts, directly overlain on the existing word cyber_x, security_x, y = -8.5, 100, 200 opacity = 0 cyber_text = codesters.Text("cyber", -8.5, 200, "orange") cyber_text.set_text_size(40) cyber_text.set_text_background("silver", "silver", opacity) security_text = codesters.Text("security", 110, 200, "aqua") security_text.set_text_size(40) security_text.set_text_background("silver", "silver", opacity) stage.wait(1) # Move the word parts down and out while darkening the background for counter in range(75): # delta_x for each is 391.5 290 opacity += .011 cyber_x -= 5.22 security_x += 4 y -= 2 cyber_text.set_text_background("silver", "white", opacity) security_text.set_text_background("silver", "white", opacity) cyber_text.go_to(cyber_x, y) security_text.go_to(security_x, y) guide_text_2.set_text("Click each part to see its definition!") lock_click, computer_click = False, False def stage_blank(): """ Removes all sprites from the stage except specified sprites to keep Stops the interval event, then hides specified sprites """ demo.remove_all_sprites_except(keep_stage_elements+ chars) stage.event_interval(None) for index, item in enumerate(keep_stage_elements): if index == 7 or index == 8: continue else: item.hide() for char in chars: char.hide() def stage_reset(): """ Sets the stage to its appearance before the stage_blank() function ran. Shows sprites and resets the interval event. Checks for if certain objects were clicked to show more elements and unpause the demo """ global computer_click, lock_click guide_text.set_text("What is cybersecurity?") stage.set_background_color("black") for index, item in enumerate(keep_stage_elements): if index == 7 or index == 8 or index == 2 or index == 5: continue else: item.show() for char in chars: char.show() stage.event_interval(interval, .05) if computer_click: cyber_def.set_color("orange") cyber_def.show() if lock_click: security_def.set_color("aqua") security_def.show() def cyber_click(sprite): """ Runs when the user clicks on the cyber word to illustrate the definition """ global computer_click computer_click = True stage_blank() lightener.show() guide_text.set_text("CYBER:") guide_text_2.set_text("involving computers or networks") stage.set_background("e2f02b00a2474375b133e2b4a3d7d6f3") # stage.set_background("https://cdn.pixabay.com/photo/2016/07/19/07/59/system-1527684_960_720.jpg") stage.set_background_scale(.85) stage.set_background_x(-545) stage.set_background_y(400) # comp_back = codesters.Rectangle(0, -100, 230, 200, "white") # computer = demo.create_sprite_off_screen("computer_30a", 0, -100, 1) # computer.set_say_position(-30, 45, "absolute") stage.wait(2) click_text = codesters.Text("Click me!", 5, -150, "white") click_text.set_text_size(30) click_text.set_text_background("black", "black", 1) # computer.say("Click me!", 0, "white", 30) click_text.event_click(ready_click) def security_click(sprite): """ Runs when the user clicks on the security word to illustrate the definition """ global lock_click lock_click = True stage_blank() guide_text.set_text("SECURITY:") guide_text_2.set_text("Having to do with being secure or safe") stage.set_background("42b83f26eed841ae82f372a549d64dbe") lock = demo.create_sprite_off_screen("open_lock_ff4", 0, -100, 2.5) lock_2 = demo.create_sprite_off_screen("closed_lock_0c7", 0, -100, 2.5) lock_2.hide() stage.wait(1) lock.hide() lock_2.show() lock_2.set_say_position(0, -75, "absolute") stage.wait(2) lock_2.say("Click me!", 0, "darkslategrey", 30) lock_2.event_click(ready_click) def ready_click(sprite): """ Checks if all clicks have happened and unpauses the demo """ global computer_click, lock_click sprite.event_click(None) stage.remove_sprite(sprite) stage_reset() if computer_click and lock_click: demo.continue_action() demo.unpause() cyber_overlay = codesters.Rectangle(-400, 50, 118, 70, "orange") cyber_overlay.set_opacity(0.01) security_overlay = codesters.Rectangle(400, 50, 118, 70, "teal") security_overlay.set_opacity(0.01) cyber_overlay.event_click(cyber_click) security_overlay.event_click(security_click) cyber_def = codesters.Text("having to do with\ncomputers and networks", -400, 0, None) security_def = codesters.Text("having to do with\nbeing secure or safe", 400, 0, None) keep_stage_elements = [security_text, security_overlay, security_def, cyber_text, cyber_overlay, cyber_def, guide, guide_text, guide_text_2, lightener] demo.pause() demo.remove_all_sprites_except([guide, guide_text, guide_text_2] + chars) guide_text_2.hide() guide_text.set_text_size(20) guide_text.set_text("When learning cybersecurity, we will be talking about two big ideas!\n\n\n\n") stage.wait(3) comp_back = codesters.Ellipse(-300, -100, 300, 240, "burlywood") computer = demo.create_sprite_off_screen("computer_30a", -300, -100, 1) guide_text.set_text("When learning cybersecurity, we will be talking about two big ideas!\n\n1) Computers\n\n") stage.wait(2.5) guide_text.set_text("When learning cybersecurity, we will be talking about two big ideas!\n\n1) Computers\n\n2) Security") lock = demo.create_sprite_off_screen("closed_lock_0c7", 300, -100, 2.05) stage.wait(2) guide_text_2.set_text("Click the blue Next button to continue!") guide_text_2.show() stage.wait(1) demo.continue_action() guide_text_2.hide() guide_text.set_text("Cybersecurity is all about building secure computer systems that we can trust!\n\n") stage.wait(1) text = u"★" + " Cybersecurity is all about building secure computer systems that we can trust! " text_sprite = demo.animate_typing_text(text, 0, 100, align="center", font_size=25, color = "white", cursor_wait = False) guide_text.hide() text_sprite.move_up(150) stage.wait(2) demo.continue_action() guide_text.set_text("What is a system? What does it mean to be secure?") guide_text.show() stage.wait(1) guide_text_2.set_text("Click Submit and Continue to begin the next activity and find out!") guide_text_2.show() old_guide = guide guide = demo.create_sprite_off_screen("person20", 0, -110, 1.25) old_guide.hide() guide.move_forward(stage_width/2+75) sprite_list = demo.remind_student_to_submit(guide_text_2.get_x() - 175, guide_text_2.get_y() - 60, 25) for sprite in sprite_list: if sprite.get_name() == 'line' or sprite.get_name() == 'arrowLine': sprite.set_color("white") elif sprite.get_text() != None: sprite.set_color("white") tester = TestManager() tester.display_success_message("Great job!") stage.wait(10) stage.event_interval(None)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)